﻿Imports Microsoft.VisualBasic

Public Class Utils

    Private Shared _RelativeWebRoot As String
    Public Shared ReadOnly Property RelativeWebRoot As String
        Get
            If _RelativeWebRoot Is Nothing Then
                _RelativeWebRoot = VirtualPathUtility.ToAbsolute("~/")
            End If
            Return _RelativeWebRoot
        End Get
    End Property
    Public Shared Function StripHtml(ByVal html As String) As String
        Dim objRegExp As Regex
        Dim strOutput As String = String.Empty
        objRegExp = New Regex("<(.|\n)+?>", RegexOptions.IgnoreCase)
        'Replace all HTML tag matches with the empty string
        strOutput = objRegExp.Replace(html, "")
        'Replace all < and > with &lt; and &gt;
        strOutput = Replace(strOutput, "<", "&lt;")
        strOutput = Replace(strOutput, ">", "&gt;")
        StripHtml = strOutput    'Return the value of strOutput
    End Function
    'Public Shared Function SendMessage(ByVal msgContent As String) As Boolean
    '    Dim b As Boolean = False
    '    Dim msg As New System.Net.Mail.MailMessage
    '    msg.To.Add(SiteSettings.SiteContactEmail)
    '    msg.From = New System.Net.Mail.MailAddress(SiteSettings.SiteFromEmail)
    '    msg.Subject = "[Contact from " & SiteSettings.SiteTitle & "]"
    '    msg.Body = msgContent
    '    Try
    '        Dim sm As New System.Net.Mail.SmtpClient()
    '        sm.Host = SiteSettings.SiteEmailServer
    '        Dim cred As New System.Net.NetworkCredential
    '        cred.UserName = SiteSettings.SiteEmailUsername
    '        cred.Password = SiteSettings.SiteEmailPassword
    '        sm.Credentials = cred
    '        sm.Send(msg)
    '        b = True
    '    Catch ex As Exception
    '        ErrorLog.LogErrors(ex)
    '        b = False
    '    End Try
    '    Return b
    'End Function
    Public Shared Sub RegisterRoutes(ByVal routes As System.Web.Routing.RouteCollection)
        routes.MapPageRoute("Item-Routes", "item/{item}", "~/Details.aspx", False)
        routes.MapPageRoute("Vendor-Routes", "vendor/{vendor}", "~/Vendor.aspx", False)
        routes.MapPageRoute("User-Routes", "Members/{user}", "~/Account/Profile.aspx", False)
    End Sub
End Class
